package com.utooo.controller;

import com.utooo.constant.ResultCodeConstant;
import com.utooo.pojo.dto.common.RestResult;
import com.utooo.pojo.query.QueryGroup;
import com.utooo.pojo.query.SupplierQuery;
import com.utooo.pojo.vo.supplier.SupplierListVO;
import com.utooo.service.supplier.SupplierArchiveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 供应商管理
 *
 * @author CK
 * @date 2025-04-17 09:19:38
 */
@Tag(name = "供应商管理")
@RequestMapping("supplier")
@RestController
public class SupplierController {

    @Autowired
    private SupplierArchiveService supplierArchiveService;

    /*

    *//**
     * 新增供应商:将供应商数据保存到数据库
     *
     * @param supplierDTO 供应商管理:供应商信息实体类
     * @return
     *//*
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @Operation(summary = "新增供应商:将供应商数据保存到数据库")
    @ResponseBody
    public RestResult<Boolean> addSupplier(@RequestBody @Validated(CreateGroup.class) SupplierDTO supplierDTO) {
        Boolean result = supplierService.addSupplier(supplierDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    *//**
     * 修改供应商:将供应商数据更新到数据库
     *
     * @param supplierDTO 供应商管理:供应商信息实体类
     * @return
     *//*
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @Operation(summary = "修改供应商:将供应商数据更新到数据库")
    @ResponseBody
    public RestResult<Boolean> updateSupplier(@RequestBody @Validated(UpdateGroup.class) SupplierDTO supplierDTO) {
        Boolean result = supplierService.updateSupplier(supplierDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    *//**
     * 删除供应商:删除供应商信息
     *
     * @param supplierDTO 供应商管理:供应商信息实体类
     * @return
     *//*
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @Operation(summary = "删除供应商:删除供应商信息")
    @ResponseBody
    public RestResult<Boolean> deleteSupplier(@RequestBody @Validated(DeleteGroup.class) SupplierDTO supplierDTO) {
        Boolean result = supplierService.deleteSupplier(supplierDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }*/


    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @Operation(summary = "查询供应商:如果查询结果为空，返回失败信息")
    public RestResult<List<SupplierListVO>> getSupplierList(@Validated(QueryGroup.class) SupplierQuery supplierQuery) {
        List<SupplierListVO> result = supplierArchiveService.getSupplierArchiveList(supplierQuery);
        return new RestResult<>(ResultCodeConstant.CODE_200, ResultCodeConstant.CODE_200_MSG, result);
    }
}
